import pdb, sys
# pdb.set_trace()
# sys.path.append(r'D:\git\gitServer\server\music')
# from music import fileStore
from fileStore import Store
from branch.models import *
import os
f = Store()

# folderAddress = 'D:\\git\\musicxml'
folderAddress = 'D:\\大创\\乐谱库\\中国音乐家协会\\2\\练习曲'
def get_files(path='D:\\xx', rule=".musicxml"):
    all = []
    # pdb.set_trace()
    for fpathe,dirs,fs in os.walk(path):   # os.walk是获取所有的目录
        for f in fs:
            filename = os.path.join(fpathe,f)
            if filename.endswith(rule):  # 判断是否是"xxx"结尾
                all.append(filename)
    return all

if __name__ == '__main__':
    # pdb.set_trace()
    b = get_files(path=folderAddress)
    for i in b:
        fileId = f.upload_and_return_id(i, fileType=1)
        print(i + '\n' + str(fileId))

